<?php
namespace app\admin\validate;

use think\Validate;

class Article extends Validate
{
    protected $rule = [
        'title'      => 'require|unique:article',
        'views'      => 'require|number|checkviews:0',
        '__token__'  =>  'require|token',
    ];
    protected $message  =   [
        'title.require'        => '标题必须填写',
        'title.unique'         => '该标题已存在', 
        'views.require'        => '点击次数不能为空',
        'views.number'         => '浏览次数必须是数字', 
        'views.checkviews'     => '浏览次数必须大于0',
        '__token__.require'    =>'非法提交',
        '__token__.token'      =>'请勿重复提交表单',
    ];
    protected $scene = [
        
    ];
    // 自定义验证规则
    protected function checkviews($value,$rule)
    {
        if ($value>$rule) {
           return true;
        }
        return false;
    }
}